import App from './App.vue'
import router from './router'
import piniaPersist from 'pinia-plugin-persist'
import { verifyAuth } from './system-auth'
import microApp from '@micro-zoe/micro-app'
import config from '@/config'
import vue3SeamlessScroll from 'vue3-seamless-scroll'

/**
 * 样式导入
 */
import 'virtual:svg-icons-register'
import '@/styles/element-plus-css-vars.scss'
import 'element-plus/theme-chalk/index.css'
import '@/styles/common.scss'
import '@/styles/reset-mapbox.scss'

/**
 * dayjs定义
 */
import dayjs from 'dayjs'
import 'dayjs/locale/zh-cn'
dayjs.locale('zh-cn')

/**
 * 微前端配置
 */
microApp.start({
    'router-mode': 'native-scope',
    preFetchApps: () => {
        return config.microAppList
    },
})

/**
 * app设置
 */
const pinia = createPinia()
pinia.use(piniaPersist)
const app = createApp(App)
app.use(router)
app.use(pinia)
app.use(vue3SeamlessScroll, { name: 'vue3SeamlessScroll' })

/**
 * 加载页面前的校验
 */
verifyAuth().then(() => {
    const pageLoadingEle = document.querySelector('.entry-page-loading')
    if (pageLoadingEle) {
        pageLoadingEle.setAttribute('style', 'display: none;')
    }
    app.mount('#app')
})
